home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
impressario
/
src
/
examples
/
libimp
/
impstat.c.z
/
impstat.c
Wrap
C/C++ Source or Header
|
1996-05-06
|
5KB
|
195 lines
/**************************************************************************
*
* Copyright (c) 1993 Silicon Graphics, Inc.
* All Rights Reserved
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
*
* The copyright notice above does not evidence any actual of intended
* publication of such source code, and is an unpublished work by Silicon
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is
* the property of Silicon Graphics, Inc. Any use, duplication or
* disclosure not specifically authorized by Silicon Graphics is strictly
* prohibited.
*
* RESTRICTED RIGHTS LEGEND:
*
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
* Technical Data and Computer Software clause at DFARS 52.227-7013,
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR
* Supplement. Unpublished - rights reserved under the Copyright Laws of
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.
* Shoreline Blvd., Mountain View, CA 94039-7311
**************************************************************************
*
* File: impstat.c
*
* Description: Prints to stdout the SGI image header information found
* in the specified image file(s).
*
* Usage: imstat [-o offset] image ...
*
* Where:
*
* -o Specifies an offset into the file where the SGI image
* starts. Default is 0.
*
**************************************************************************/
#ident "$Revision: 1.2 $"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "imp.h"
/* Local functions */
static void usage(char *progName);
/**************************************************************************
*
* Function: main
*
* Description: Program entry point
*
* Parameters:
* argc (I) - number of command line arguments
* argv (I) - command line arguments
*
* Return: 0 if no errors, 1 otherwise.
*
**************************************************************************/
int main(int argc, char *argv[])
{
IMPImage *image;
register int i, ch;
char *fname, *pname;
off_t offset = 0;
/*
* Extract the program basename
*/
pname = ((pname = strrchr(argv[0], '/')) == NULL) ? argv[0]: pname + 1;
/*
* Handle command line options
*/
while ((ch = getopt(argc, argv, "o:")) != EOF) {
switch (ch) {
case 'o':
offset = atoi(optarg);
break;
case '?':
default:
usage(pname);
exit(1);
}
}
/*
* Check the argument count
*/
if (argc - optind < 1) {
usage(pname);
exit(1);
}
/*
* Cycle through each image printing information
*/
for (i = optind; i < argc; i++) {
/*
* Open the image for reading
*/
if ((image = impOpenExt(argv[i], "r", offset, IMPNoCache)) == NULL) {
impPerror(pname);
exit(1);
}
/*
* Extract the file's basename
*/
fname = ((fname = strrchr(argv[i], '/')) == NULL) ? argv[i]: fname + 1;
/*
* Print header information
*/
printf("Filename: %s\n", fname);
printf("Header Name: '%s'\n", impName(image));
printf("X Size: %d\n", impXSize(image));
printf("Y Size: %d\n", impYSize(image));
printf("Num. Channels: %d\n", impNumChannels(image));
printf("Dimension: %d\n", impDimension(image));
printf("Min Value: %d\n", impMinValue(image));
printf("Max Value: %d\n", impMaxValue(image));
printf("Bytes Per Pixel: %d\n", impRasterBPP(image));
printf("Raster Encoding: %s\n",
(impRasterEncoding(image) == IMP_RASTER_ENC_RLE) ?
"RLE": "VERBATIM");
printf("Image Type: ");
switch (impImageType(image)) {
case IMP_IMAGE_NORMAL:
printf("NORMAL\n");
break;
case IMP_IMAGE_DITHERED:
printf("DITHERED\n");
break;
case IMP_IMAGE_SCREEN:
printf("SCREEN\n");
break;
case IMP_IMAGE_COLORMAP:
printf("COLORMAP\n");
break;
default:
printf("%8X\n", impImageType(image));
break;
}
if (argc > 2)
printf("\n");
/*
* Close the image
*/
if (impClose(image) < 0) {
impPerror(pname);
exit(1);
}
}
return 0;
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: usage
*
* Description: Prints the program usage to stderr.
*
* Parameters:
* progName (I) - name of program
*
* Return: none
*
**************************************************************************/
static void usage(char *progName)
{
fprintf(stderr, "Usage: %s [-o offset] image ...\n", progName);
}